package com.hk.service.impl;

import com.hk.dao.OnlineMessageDao;
import com.hk.model.OnlineMessage;
import com.hk.service.IOnlineMessageService;

import java.util.List;

/**
 * @Author: KangWang
 * Date: 2021/5/20 16:09
 * State：在线留言业务逻辑层
 */
public class OnlineMessageServiceImpl implements IOnlineMessageService {

    OnlineMessageDao onlineMessageDao = new OnlineMessageDao();
    //        设定一个默认变量为0，用于检测是否新增成功
    int count = 0;

    @Override
    public void saveMessage(OnlineMessage onlineMessage) {
        List<OnlineMessage> onlineMessageList = onlineMessageDao.saveMessage(onlineMessage);
        if (onlineMessageList.size() < count) {
            System.out.println("留言失败");
        }
        System.out.println(
                "新增留言：" +
                        "标题：" + onlineMessage.getMessageTitle() +
                        "邮箱：" + onlineMessage.getMessageEmail() +
                        "内容：" + onlineMessage.getMessageContent()
        );
        System.out.println(onlineMessageList);
        count = onlineMessageList.size();
    }
}
